package o;

import androidx.annotation.Nullable;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import java.nio.charset.Charset;

public final class anc {
    private int ˊ;
    private int ˎ;
    public byte[] ˏ;

    public anc() {
        this.ˏ = anr.ʽ;
    }

    public anc(int i) {
        this.ˏ = new byte[i];
        this.ˎ = i;
    }

    public anc(byte[] bArr) {
        this.ˏ = bArr;
        this.ˎ = bArr.length;
    }

    public anc(byte[] bArr, int i) {
        this.ˏ = bArr;
        this.ˎ = i;
    }

    public void ˏ() {
        this.ˊ = 0;
        this.ˎ = 0;
    }

    public void ˏ(int i) {
        ॱ(ˎ() < i ? new byte[i] : this.ˏ, i);
    }

    public void ˋ(byte[] bArr) {
        ॱ(bArr, bArr.length);
    }

    public void ॱ(byte[] bArr, int i) {
        this.ˏ = bArr;
        this.ˎ = i;
        this.ˊ = 0;
    }

    public int ˊ() {
        return this.ˎ - this.ˊ;
    }

    public int ॱ() {
        return this.ˎ;
    }

    public void ॱ(int i) {
        boolean z = i >= 0 && i <= this.ˏ.length;
        amm.ˊ(z);
        this.ˎ = i;
    }

    public int ˋ() {
        return this.ˊ;
    }

    public int ˎ() {
        return this.ˏ.length;
    }

    public void ˋ(int i) {
        boolean z = i >= 0 && i <= this.ˎ;
        amm.ˊ(z);
        this.ˊ = i;
    }

    public void ˎ(int i) {
        ˋ(this.ˊ + i);
    }

    public void ॱ(ane o_ane, int i) {
        ˎ(o_ane.ˎ, 0, i);
        o_ane.ˋ(0);
    }

    public void ˎ(byte[] bArr, int i, int i2) {
        System.arraycopy(this.ˏ, this.ˊ, bArr, i, i2);
        this.ˊ += i2;
    }

    public int ʻ() {
        return this.ˏ[this.ˊ] & 255;
    }

    public char ᐝ() {
        return (char) (((this.ˏ[this.ˊ] & 255) << 8) | (this.ˏ[this.ˊ + 1] & 255));
    }

    public int ʽ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        return bArr[i] & 255;
    }

    public int ॱॱ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        int i2 = (bArr[i] & 255) << 8;
        byte[] bArr2 = this.ˏ;
        int i3 = this.ˊ;
        this.ˊ = i3 + 1;
        return i2 | (bArr2[i3] & 255);
    }

    public int ʼ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        int i2 = bArr[i] & 255;
        byte[] bArr2 = this.ˏ;
        int i3 = this.ˊ;
        this.ˊ = i3 + 1;
        return i2 | ((bArr2[i3] & 255) << 8);
    }

    public short ˊॱ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        int i2 = (bArr[i] & 255) << 8;
        byte[] bArr2 = this.ˏ;
        int i3 = this.ˊ;
        this.ˊ = i3 + 1;
        return (short) (i2 | (bArr2[i3] & 255));
    }

    public int ˏॱ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        int i2 = (bArr[i] & 255) << 16;
        byte[] bArr2 = this.ˏ;
        int i3 = this.ˊ;
        this.ˊ = i3 + 1;
        i2 |= (bArr2[i3] & 255) << 8;
        bArr2 = this.ˏ;
        i3 = this.ˊ;
        this.ˊ = i3 + 1;
        return i2 | (bArr2[i3] & 255);
    }

    public int ͺ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        int i2 = ((bArr[i] & 255) << 24) >> 8;
        byte[] bArr2 = this.ˏ;
        int i3 = this.ˊ;
        this.ˊ = i3 + 1;
        i2 |= (bArr2[i3] & 255) << 8;
        bArr2 = this.ˏ;
        i3 = this.ˊ;
        this.ˊ = i3 + 1;
        return i2 | (bArr2[i3] & 255);
    }

    public long ˋॱ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        long j = (((long) bArr[i]) & 255) << 24;
        byte[] bArr2 = this.ˏ;
        int i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 16;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 8;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        return j | (((long) bArr2[i2]) & 255);
    }

    public long ॱˊ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        long j = ((long) bArr[i]) & 255;
        byte[] bArr2 = this.ˏ;
        int i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 8;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 16;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        return j | ((((long) bArr2[i2]) & 255) << 24);
    }

    public int ॱᐝ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        int i2 = (bArr[i] & 255) << 24;
        byte[] bArr2 = this.ˏ;
        int i3 = this.ˊ;
        this.ˊ = i3 + 1;
        i2 |= (bArr2[i3] & 255) << 16;
        bArr2 = this.ˏ;
        i3 = this.ˊ;
        this.ˊ = i3 + 1;
        i2 |= (bArr2[i3] & 255) << 8;
        bArr2 = this.ˏ;
        i3 = this.ˊ;
        this.ˊ = i3 + 1;
        return i2 | (bArr2[i3] & 255);
    }

    public int ᐝॱ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        int i2 = bArr[i] & 255;
        byte[] bArr2 = this.ˏ;
        int i3 = this.ˊ;
        this.ˊ = i3 + 1;
        i2 |= (bArr2[i3] & 255) << 8;
        bArr2 = this.ˏ;
        i3 = this.ˊ;
        this.ˊ = i3 + 1;
        i2 |= (bArr2[i3] & 255) << 16;
        bArr2 = this.ˏ;
        i3 = this.ˊ;
        this.ˊ = i3 + 1;
        return i2 | ((bArr2[i3] & 255) << 24);
    }

    public long ॱˎ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        long j = (((long) bArr[i]) & 255) << 56;
        byte[] bArr2 = this.ˏ;
        int i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 48;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 40;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 32;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 24;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 16;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 8;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        return j | (((long) bArr2[i2]) & 255);
    }

    public long ʻॱ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        long j = ((long) bArr[i]) & 255;
        byte[] bArr2 = this.ˏ;
        int i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 8;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 16;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 24;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 32;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 40;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        j |= (((long) bArr2[i2]) & 255) << 48;
        bArr2 = this.ˏ;
        i2 = this.ˊ;
        this.ˊ = i2 + 1;
        return j | ((((long) bArr2[i2]) & 255) << 56);
    }

    public int ॱˋ() {
        byte[] bArr = this.ˏ;
        int i = this.ˊ;
        this.ˊ = i + 1;
        int i2 = (bArr[i] & 255) << 8;
        byte[] bArr2 = this.ˏ;
        int i3 = this.ˊ;
        this.ˊ = i3 + 1;
        i2 |= bArr2[i3] & 255;
        this.ˊ += 2;
        return i2;
    }

    public int ʿ() {
        return (((ʽ() << 21) | (ʽ() << 14)) | (ʽ() << 7)) | ʽ();
    }

    public int ʽॱ() {
        int ॱᐝ = ॱᐝ();
        if (ॱᐝ >= 0) {
            return ॱᐝ;
        }
        throw new IllegalStateException("Top bit not zero: " + ॱᐝ);
    }

    public int ʾ() {
        int ᐝॱ = ᐝॱ();
        if (ᐝॱ >= 0) {
            return ᐝॱ;
        }
        throw new IllegalStateException("Top bit not zero: " + ᐝॱ);
    }

    public long ʼॱ() {
        long ॱˎ = ॱˎ();
        if (ॱˎ >= 0) {
            return ॱˎ;
        }
        throw new IllegalStateException("Top bit not zero: " + ॱˎ);
    }

    public double ˈ() {
        return Double.longBitsToDouble(ॱˎ());
    }

    public String ˊ(int i) {
        return ˊ(i, Charset.forName("UTF-8"));
    }

    public String ˊ(int i, Charset charset) {
        String str = new String(this.ˏ, this.ˊ, i, charset);
        this.ˊ += i;
        return str;
    }

    public String ʻ(int i) {
        if (i == 0) {
            return "";
        }
        int i2 = (this.ˊ + i) - 1;
        if (i2 >= this.ˎ || this.ˏ[i2] != (byte) 0) {
            i2 = i;
        } else {
            i2 = i - 1;
        }
        String ˊ = anr.ˊ(this.ˏ, this.ˊ, i2);
        this.ˊ += i;
        return ˊ;
    }

    @Nullable
    public String ˉ() {
        if (ˊ() == 0) {
            return null;
        }
        int i = this.ˊ;
        while (i < this.ˎ && this.ˏ[i] != (byte) 0) {
            i++;
        }
        String ˊ = anr.ˊ(this.ˏ, this.ˊ, i - this.ˊ);
        this.ˊ = i;
        if (this.ˊ < this.ˎ) {
            this.ˊ++;
        }
        return ˊ;
    }

    @Nullable
    public String ˊˋ() {
        if (ˊ() == 0) {
            return null;
        }
        int i = this.ˊ;
        while (i < this.ˎ && !anr.ˎ(this.ˏ[i])) {
            i++;
        }
        if (i - this.ˊ >= 3 && this.ˏ[this.ˊ] == (byte) -17 && this.ˏ[this.ˊ + 1] == (byte) -69 && this.ˏ[this.ˊ + 2] == (byte) -65) {
            this.ˊ += 3;
        }
        String ˊ = anr.ˊ(this.ˏ, this.ˊ, i - this.ˊ);
        this.ˊ = i;
        if (this.ˊ == this.ˎ) {
            return ˊ;
        }
        if (this.ˏ[this.ˊ] == (byte) 13) {
            this.ˊ++;
            if (this.ˊ == this.ˎ) {
                return ˊ;
            }
        }
        if (this.ˏ[this.ˊ] == (byte) 10) {
            this.ˊ++;
        }
        return ˊ;
    }

    public long ˊˊ() {
        int i = 1;
        int i2 = 0;
        long j = (long) this.ˏ[this.ˊ];
        for (int i3 = 7; i3 >= 0; i3--) {
            byte b;
            if ((((long) (1 << i3)) & j) == 0) {
                if (i3 < 6) {
                    j &= (long) ((1 << i3) - 1);
                    i2 = 7 - i3;
                } else if (i3 == 7) {
                    i2 = 1;
                }
                if (i2 != 0) {
                    throw new NumberFormatException("Invalid UTF-8 sequence first byte: " + j);
                }
                while (i < i2) {
                    b = this.ˏ[this.ˊ + i];
                    if ((b & 192) == DnsConfig.MAX_CACHE_ENTRIES) {
                        throw new NumberFormatException("Invalid UTF-8 sequence continuation byte: " + j);
                    }
                    j = (j << 6) | ((long) (b & 63));
                    i++;
                }
                this.ˊ += i2;
                return j;
            }
        }
        if (i2 != 0) {
            while (i < i2) {
                b = this.ˏ[this.ˊ + i];
                if ((b & 192) == DnsConfig.MAX_CACHE_ENTRIES) {
                    j = (j << 6) | ((long) (b & 63));
                    i++;
                } else {
                    throw new NumberFormatException("Invalid UTF-8 sequence continuation byte: " + j);
                }
            }
            this.ˊ += i2;
            return j;
        }
        throw new NumberFormatException("Invalid UTF-8 sequence first byte: " + j);
    }
}
